const tree = {
    name: 'root',
    children: [
        { name: '叶子1-1' },
        { name: '叶子1-2' },
        {
            name: '叶子2-1',
            children: [{
                name: '叶子3-1',
                children: [{
                    name: '叶子4-1',
                    children: [{}]
                }]
            }]
        }
    ]
}
let maxDepth = 0
function computeDepth(tree,depth) {
    if (maxDepth < depth) {
        console.log('lai')
        maxDepth = depth
    }
    const {name, children} = tree
    if (!children) return
    if (Array.from(children)) {
        children.forEach(item => computeDepth(item,depth + 1))
    }
}
computeDepth(tree,1)
console.log(maxDepth);
